/*
 *  Copyright (C) 1998-2020 by Northwoods Software Corporation. All Rights Reserved.
 */

import * as React from 'react';
import { InspectorContext } from '../FlowManage';

// import { InspectorRow } from "./InspectorRow";

import './Inspector.css';
// import { Form, Switch, Input } from "antd";
import EndComponent from './EndComponent';
import InfoCollectionComponent from './InfoCollectionComponent';
import KeyComponent from './KeyComponent';
import TransferManualServiceComponent from './TransferManualServiceComponent';
import InterfaceComponent from './InterfaceComponent';
import IntentComponent from './IntentComponent';
import ConditionComponent from './ConditionComponent';
import SkipComponent from './SkipComponent';

/**
 * 当前选中的组件的检查器
 * 示例：AI管理-机器人管理-版本管理-配置话术流程
 */
export class SelectionInspectorCopy extends React.PureComponent {
  // 不能在组件销毁后设置state，防止出现内存泄漏的情况
  componentWillUnmount = () => {
    this.setState = (state, callback) => {
      return;
    };
  };

  renderObjectDetails = (category: string, key: number) => {
    // console.log('category+key:::', category, key);
    switch (category) {
      // 结束组件
      case 'EndComponent':
        return <EndComponent key={category + key} />;
      case 'SkipComponent':
        return <SkipComponent key={category + key} />;
      case 'InfoCollectionComponent':
        return <InfoCollectionComponent key={category + key} />;
      case 'KeyComponent':
        return <KeyComponent key={category + key} />;
      case 'TransferManualServiceComponent':
        return <TransferManualServiceComponent key={category + key} />;
      case 'InterfaceComponent':
        return <InterfaceComponent key={category + key} />;
      case 'IntentComponent':
        return <IntentComponent key={category + key} />;
      case 'ConditionComponent':
        return <ConditionComponent key={category + key} />;
    }
  };

  public render() {
    console.log('SelectionInspector***Render');

    return (
      <InspectorContext.Consumer>
        {({ category, selectedData }) => (
          <div id="myInspectorDiv" className="inspector">
            {this.renderObjectDetails(category, selectedData.key)}
          </div>
        )}
      </InspectorContext.Consumer>
    );
  }
}
